package com.wjp.dinosaur.handler;

import com.wjp.dinosaur.vo.Result;
import org.springframework.http.converter.HttpMessageNotReadableException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;


// 对加了@Controller的注解进行拦截处理 AOP实现
@ControllerAdvice
public class AllExceptionHandler {
    @ExceptionHandler(Exception.class)
    @ResponseBody   // 返回一个json数据
    public Result doExceptionHandler(Exception ex){
        ex.printStackTrace();
        return Result.fail(-999, "系统异常");
    }
}
